package com.xm;

import java.util.HashMap;

/**
 * @Author：xm
 * @Project：runoob
 * @Date：2024/7/15 11:47
 */

public class HashMap04 {
    public static void main(String[] args) {
        HashMap<Integer, String> hashMap = new HashMap<>();
        hashMap.put(1, "a");
        hashMap.put(2, "b");
        hashMap.put(3, "c");
        System.out.println("hashMap = " + hashMap);
        System.out.println("hashMap.get(2) = " + hashMap.get(2));

        System.out.println("hashMap.remove(2) = " + hashMap.remove(2));
        System.out.println("hashMap = " + hashMap);

        // 删除所有键值对
        // hashMap.clear();

        System.out.println("hashMap.size() = " + hashMap.size());

        for (Integer i : hashMap.keySet()) {
            System.out.println("key = " + i+",value= "+hashMap.get(i));
        }

        for (String value : hashMap.values()) {
            System.out.println("value = " + value);
        }
    }
}
